package com.study.talk.data.local;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.study.talk.data.model.MessageRecord;

import java.util.List;

@Dao
public interface MessageDao {

    @Insert
    void insert(MessageRecord message);

    @Insert
    void insert(List<MessageRecord> messageList);

    @Delete
    void remove(MessageRecord message);

    @Update
    void update(MessageRecord message);

    @Query("SELECT * FROM message_record")
    LiveData<List<MessageRecord>> query();

    @Query("DELETE FROM message_record")
    void clear();

    @Query("SELECT * FROM message_record WHERE chat_id=(:chatId)")
    LiveData<List<MessageRecord>> query(Integer chatId);

    @Query("UPDATE message_record SET read = 1 WHERE chat_id=(:chatId)")
    Integer update(Integer chatId);



}
